_isDebug = false;

--加载badboy库
local bb = require("badboy");
--加载utils模块
bb.loadutilslib();
--加载JSON模块
bb_json = bb.getJSON();

printFunction = function (...)
  if not _isDebug then
    do return end
  end
  local params = {...}
  local str = nil
  for k,v in pairs(params) do
    if not str then
      str = tostring(v)
    else
      str = str .. ", " .. tostring(v)
    end
  end
  printLog("[调试信息]>>>>"..str)
end

function convertBooleanToString (temp)
  if temp == nil then
    return "没有数据";
  elseif type(temp) == "boolean" then
    if temp then
      return "true";
    else
      return "false";
    end
  end
end


function convertNumberToJuexingType (number) 
  if number == 1 then
    return "火麒麟";
  elseif number == 2 then
    return "风麒麟";
  elseif number == 3 then
    return "水麒麟";
  elseif number == 4 then
    return "雷麒麟";
  end
  return "火麒麟";
end


function convertNumberToYeyuanhuoChapter (number)
  if number == 1 then
    return "贪之阵";
  elseif number == 2 then
    return "嗔之阵";
  elseif number == 3 then
    return "痴之阵";
  end
  return "八岐大蛇";
end

function convertNumberToYuhunType (number) 
  if number == 1 then
    return "八岐大蛇";
  elseif number == 2 then
    return "业原火";
  end
  return "八岐大蛇";
end

function covertNumberToYuhunJuexingChapter (number)
  if number == 1 then
    return "壹层";
  elseif number == 2 then
    return "贰层";
  elseif number == 3 then
    return "叁层";
  elseif number == 4 then
    return "肆层";
  elseif number == 5 then
    return "伍层";
  elseif number == 6 then
    return "陆层";
  elseif number == 7 then
    return "柒层";
  elseif number == 8 then
    return "捌层";
  elseif number == 9 then		
    return "玖层";
  elseif number == 10 then
    return "拾层";
  end
  return "壹层";
end



function covertNumberToMonsterChapter (number) 
  if number == 1 then
    return "第一章";
  elseif number == 2 then
    return "第二章";
  elseif number == 3 then
    return "第三章";
  elseif number == 4 then
    return "第四章";
  elseif number == 5 then
    return "第五章";
  elseif number == 6 then
    return "第六章";
  elseif number == 7 then
    return "第七章";
  elseif number == 8 then
    return "第八章";
  elseif number == 9 then		
    return "第九章";
  elseif number == 10 then
    return "第十章";
  elseif number == 11 then
    return "第十一章";
  elseif number == 12 then
    return "第十二章";
  elseif number == 13 then
    return "第十三章";
    
  elseif number == 14 then
    return "第十四章";
  elseif number == 15 then
    return "第十五章";
    
  elseif number == 16 then
    return "第十六章";
    
  elseif number == 17 then
    return "第十七章";
    
    
  elseif number == 18 then
    return "第十八章";
    
    
  elseif number == 19 then
    return "第十九章";
		
	elseif number == 20 then
    return "第二十章";
		
	elseif number ==21 then
    return "第二十一章";
		
	elseif number == 22 then
    return "第二十二章";
  end
  
  return "第一章";
end

function covertChapterToNumber (chapter)
  
  if chapter == "第一章" or chapter == "壹层" then
    return 1;
  elseif chapter == "第二章" or chapter == "贰层" then
    return 2;
  elseif chapter == "第三章" or chapter == "叁层" then
    return 3;
  elseif chapter == "第四章" or chapter == "肆层" then
    return 4;
  elseif chapter == "第五章" or chapter == "伍层" then
    return 5;
  elseif chapter == "第六章" or chapter == "陆层" then
    return 6;
  elseif chapter == "第七章" or chapter == "柒层" then
    return 7;
  elseif chapter == "第八章" or chapter == "捌层" then
    return 8;  
  elseif chapter == "第九章" or chapter == "玖层" then
    return 9;
  elseif chapter == "第十章" or chapter == "拾层" then
    return 10;
  elseif chapter == "第十一章" then
    return 11;
  elseif chapter == "第十二章" then
    return 12;
  elseif chapter == "第十三章" then
    return 13;
  elseif chapter == "第十四章" then
    return 14;
  elseif chapter == "第十五章" then
    return 15;
  elseif chapter == "第十六章" then
    return 16;
  elseif chapter == "第十七章" then
    return 17;
  elseif chapter == "第十八章" then
    return 18;
  elseif chapter == "第十九章" then
    return 19;
	elseif chapter == "第二十章" then
    return 20;
  elseif chapter == "第二十一章" then
    return 21;
  elseif chapter == "第二十二章" then
    return 22;

  else
    printLog("参数有误");
    return 0;
  end
end



-- 模拟快速滑动操作，从点(x1, y1)划到到(x2, y2)
function quickSwip(x1,y1,x2,y2)
	
	touchDown(1, x1, y1);
	mSleep(30);
	
	local step = 3;

	for tmpi=1,step do
		local x, y = x1 + ((x2 - x1)/step) * tmpi, y1 + ((y2 - y1)/step) * tmpi;
		touchMove(1, x, y);
		mSleep(20);
  end
	
	touchUp(1, x2,y2);
end

--输出
function printLog (content)
	if not _isDebug then
		return
	end
	sysLog(content);
end


-- 格式化输出table（力荐）
function printTable (root, notPrint, params)
  
  if not _isDebug then
    do return end
  end
  local rootType = type(root)
  if rootType == "table" then
    local tag = params and params.tag or "Table detail:>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
    local cache = {  [root] = "." }
    local isHead = false
    local function _dump(t, space, name)
      local temp = {}
      if not isHead then
        temp = {tag}
        isHead = true
      end
      for k,v in pairs(t) do
        local key = tostring(k)
        if cache[v] then
          table.insert(temp, "+" .. key .. " {" .. cache[v] .. "}")
        elseif type(v) == "table" then
          local new_key = name .. "." .. key
          cache[v] = new_key
          table.insert(temp, "+" .. key .. _dump(v, space .. (next(t, k) and "|" or " " ) .. string.rep(" ", #key), new_key))
        else
          table.insert(temp, "+" .. key .. " [" .. tostring(v) .. "]")
        end
      end
      return table.concat(temp, "\n" .. space)
    end
    if not notPrint then
      printLog(_dump(root, "", ""))
      printLog("<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<")
    else
      return _dump(root, "", "")
    end
  else
    printLog("[printr error]: not support type")
  end
end

--获取屏幕截图， 用于动态画面的多次取色
function getMultableSnapshot ()
  printLog("开始截图");
  
  for tmpi=1,30 do
    
    snapshot('[public]'.."点击屏幕继续"..tmpi..".png",774,345,1442,888);   --使用jpg格式截图，质量为0.9
		
    mSleep(100);		
  end
  
  printLog("完成截图");
end

